package org.hiucung.baiyun_health_report.utils;

import java.nio.charset.StandardCharsets;
import java.util.Base64;

/**
 * @author its-kicc
 * @desc 学号和密码需要使用到 Base64编码
 * @date 2021/12/7
 */
public class Base64Utils {

    //Base64编码
    public static String Encoder(String text){
        final Base64.Encoder encoder = Base64.getEncoder();
//        final String text = "20331503183";
        final byte[] textByte = text.getBytes(StandardCharsets.UTF_8);
        return encoder.encodeToString(textByte);
    }

    //Base64解码
    public static String Decoder(String text){
        final Base64.Decoder decoder = Base64.getDecoder();
        return new String(decoder.decode(text), StandardCharsets.UTF_8);
    }
}
